<template>
  <!-- 活动新增的输入框模块 -->
  <div>
    <div class="box">
      <FormPanel ref="formPanel" :list="formList" :cols="3" :labelWidth="110" formType="add" :isSubmitBtn="false" @formChange="formChangeHandle" />
    </div>
    <div>
      <LazyLoadTab v-model="activeName" :tabMenus="menus"></LazyLoadTab>
    </div>
    <el-row>
      <div class="box_02">
        <el-button size="small" icon="el-icon-refresh-left" type="primary" @click="closeDetails()">取消</el-button>
      </div>
    </el-row>
    <!-- <div v-show='false'>
     <actscope ref="actscope"></actscope>
    </div>
    <div v-show='false'>
     <actcontent ref="actcontent"></actcontent>
    </div> -->
  </div>
</template>
<script>
import moment from 'moment';
import { dictionary } from '@/utils/dictMixin';
import { getWxlxSelect } from '@/api/repair/repairReception/customer';
import { addActivity, details } from '@/api/repair/repair/activitesManage';
// import  actscope from './actscope';
// import  actcontent from './actcontent'
export default {
  name: 'detailsAddActivity',
  components: {
    // actscope,
    // actcontent
  },
  mixins: [dictionary],
  props: ['detaildata'],
  data() {
    this.saveData = {};
    return {
      formadd: false,
      formList: this.createFormList(),
      cunwxxm: [],
      cunpjxm: [],
      cunfjxm: [],
      cunactcsope: [],
      activeName: '活动内容',
      menus: this.listMenus()
    };
  },
  mounted() {
    // this.formList[16].initialValue = 10041001;
    this.getWxlxSelect();
  },
  created() {
    this.details();
  },
  methods: {
    // 获取详情信息方法
    async details() {
      let res = await details(this.detaildata);
      console.log(res);
      this.formList.forEach(x => {
        if (x.fieldName == 'beginDate' || x.fieldName == 'endDate' || x.fieldName == 'salesDateBegin' || x.fieldName == 'salesendDate') {
          if (res.data[x.fieldName] != null && res.data[x.fieldName] != undefined) {
            x.initialValue = res.data[x.fieldName].substr(0, 10) + ' 00:00:00';
          }
        } else if (x.fieldName === 'activityAmount') {
          if (res.data[x.fieldName] == null || res.data[x.fieldName] == '') {
            x.initialValue = 0;
          } else {
            x.initialValue = res.data[x.fieldName].toFixed(2);
          }
        } else {
          x.initialValue = res.data[x.fieldName];
        }
      });
    },
    formChangeHandle() {},
    closeDetails() {
      this.$emit('detailsAddActivity', false);
    },
    listMenus() {
      let that = this;
      return [
        {
          title: '活动内容',
          path: 'repair/activitiesManage/activitiesManage/Details/detailsActcontent',
          params: {
            detaildata: that.detaildata
          },
          on: {
            //   changeoneF(val) {
            //     that.cunwxxm = []
            //       if (val.length>0){
            //       val.forEach(x=>{
            //           x.fag = 'A'
            //           that.cunwxxm.push(x)
            //        })
            //   }
            // },
            //   changetwoF(val) {
            //     that.cunpjxm = []
            //       if (val.length>0){
            //        val.forEach(x =>{
            //           x.fag = 'A'
            //           that.cunpjxm.push(x)
            //        })
            //   }
            // },
            //   changethreeF(val) {
            //    that.cunfjxm = []
            //       if (val.length>0){
            //       val.forEach(x=>{
            //           x.fag = 'A'
            //           that.cunfjxm.push(x)
            //        })
            //   }
            // },
          }
        },
        {
          title: '活动范围',
          path: 'repair/activitiesManage/activitiesManage/Details/detailsActscope',
          params: {
            detaildata: that.detaildata
          },
          on: {
            // changeEmptyone(val) {
            //   that.cunactcsope = []
            //   if (val.length>0){
            //        val.forEach(x=>{
            //           x.fag = 'A'
            //           that.cunactcsope.push(x)
            //        })
            //   }
            // }
          }
        }
      ];
    },
    createFormList() {
      return [
        {
          type: 'INPUT',
          label: '活动代码',
          fieldName: 'activityCode',
          disabled: true,
          placeholder: ''
        },
        {
          type: 'INPUT',
          label: '活动名称',
          fieldName: 'activityName',
          disabled: true,
          placeholder: ''
        },
        {
          type: 'INPUT',
          label: '活动总金额',
          fieldName: 'activityAmount',
          disabled: true,
          placeholder: ''
        },
        {
          type: 'DATE',
          label: '开始-结束日期',
          fieldName: 'beginDate',
          disabled: true,
          placeholder: '',
          valueFormat: 'yyyy-MM-dd'
        },
        {
          type: 'DATE',
          label: '至',
          fieldName: 'endDate',
          disabled: true,
          placeholder: '',
          valueFormat: 'yyyy-MM-dd'
        },
        {
          type: 'SELECT',
          label: '业务类型',
          fieldName: 'businessType',
          disabled: true,
          placeholder: '',
          itemList: this.createDictList('8047')
        },
        {
          type: 'DATE',
          label: '销售日期',
          disabled: true,
          valueFormat: 'yyyy-MM-dd',
          placeholder: '',
          fieldName: 'salesDateBegin'
        },
        {
          type: 'DATE',
          label: '至',
          disabled: true,
          valueFormat: 'yyyy-MM-dd',
          placeholder: '',
          fieldName: 'salesendDate'
        },
        {
          type: 'SELECT',
          label: '活动类型',
          fieldName: 'activityType',
          placeholder: '请选择...',
          disabled: true,
          itemList: []
        },
        {
          type: 'INPUT',
          label: '行驶里程',
          fieldName: 'mileageBegin',
          placeholder: '',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '至',
          fieldName: 'mileageEnd',
          placeholder: '',
          disabled: true
        },
        {
          type: 'SELECT',
          label: '是否默认参与',
          fieldName: 'isActity',
          disabled: true,
          placeholder: '',
          initialValue: '',
          itemList: this.createDictList('1004')
        },
        //   {
        //   type: 'SELECT',
        //   label: '是否备件活动',
        //   fieldName: 'isPartActivity',
        //   disabled: true,
        //   placeholder: '',
        //   itemList: this.createDictList('1004')
        // },
        {
          type: 'INPUT',
          label: '销售天数',
          fieldName: 'salesBeginDay',
          disabled: true,
          placeholder: ''
        },
        {
          type: 'INPUT',
          label: '至',
          fieldName: 'salesEndDay',
          disabled: true,
          placeholder: ''
        },
        {
          type: 'SELECT',
          label: '备件是否可编辑',
          fieldName: 'partsIsModify',
          placeholder: '',
          disabled: true,
          initialValue: '',
          itemList: this.createDictList('1004')
        },
        {
          type: 'SELECT',
          label: '是否多次参加活动',
          fieldName: 'isRepeatAttend',
          placeholder: '',
          initialValue: '',
          disabled: true,
          itemList: this.createDictList('1004')
        },
        {
          type: 'SELECT',
          label: '是否邀约',
          fieldName: 'isActityBooking',
          placeholder: '',
          disabled: true,
          initialValue: '',
          itemList: this.createDictList('1004')
        }
      ];
    },
    async getFwhdXqList(row) {
      const res = await getFwhdXqList(row);
      this.formList.forEach(x => {
        if (x.fieldName === 'ACTIVITY_KIND') {
          x.initialValue = Number(res[x.fieldName]);
        } else if (
          x.fieldName === 'BEGIN_DATE' ||
          x.fieldName === 'END_DATE' ||
          x.fieldName === 'SALES_DATE_BEGIN' ||
          x.fieldName === 'SALES_DATE_END' ||
          x.fieldName === 'MAINTAIN_BEGIN_DATE' ||
          x.fieldName === 'MAINTAIN_END_DATE'
        ) {
          x.initialValue = moment(res[x.fieldName]).format('YYYY-MM-DD');
        } else {
          x.initialValue = res[x.fieldName];
        }
      });
    },
    async getWxlxSelect() {
      const res = await getWxlxSelect();
      this.formList.find(x => x.fieldName === 'activityType').itemList = res.data.map(x => ({ value: x.REPAIR_TYPE_CODE, text: x.REPAIR_TYPE_NAME }));
    },
    async getbrandList() {
      const res = await getbrandList();
    }
  }
};
</script>
<style lang="less" scoped>
.box {
  border: 1px solid #ccc;
  padding-top: 15px;
  padding-right: 15px;
  border-radius: @borderRadius;
  margin-bottom: 20px;
  box-shadow: @boxShadow;
}
.box_02 {
  text-align: center;
  margin-top: 20px;
}
</style>

// 点击之后的弹框是否确认的方法 // delQuestion() { // this.$confirm('是否确认删除?', '提示', { // confirmButtonText: '确定', // cancelButtonText: '取消', // type: 'warning' // }) // .then(() => { //
this.$emit('close', false); // }) // .catch(() => {}); // },
